function [ smoothedVelData ] = fitAndSmoothVelocityDataGUI( conCompMaxVals, flagFit, windowedImg, inputAxes, instructionText )
%UNTITLED2 Summary of this function goes here
%   Detailed explanation goes here

%fits a 6th degree polynomial to the flow data. Prompts for user input on
%whether or not the fit is good. If not good, allows the user to manually
%specify parts of the curve. This function will be exited once the user
%approves the fit.

while flagFit == 0
    [ PolyFitResult, S, mu ] = polyfit(conCompMaxVals(:,1),conCompMaxVals(:,2), 6);

    smoothedVelData(:, 1) = conCompMaxVals(:, 1);
    smoothedVelData(:, 2) = polyval(PolyFitResult, conCompMaxVals(:, 1),[],mu);
    
    %Checks with user to ensure curve fitting is accurate. Change curve fit if necessary
    [conCompMaxVals, flagFit] = EvaluateVelocityFitGUI(smoothedVelData, windowedImg, conCompMaxVals, flagFit, inputAxes, instructionText);
end

    [ PolyFitResult, S, mu ] = polyfit(conCompMaxVals(:,1),conCompMaxVals(:,2), 6);

smoothedVelData(:, 1) = conCompMaxVals(:, 1);
smoothedVelData(:, 2) = polyval(PolyFitResult, conCompMaxVals(:, 1),[],mu);

end

